package com.module.circle.ui.schedule

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.common.app.data.bean.circle.CircleListModel
import com.common.base.app.extras.loadRound
import com.common.base.app.extras.otherwise
import com.common.base.app.extras.yes
import com.common.base.utils.ViewUtils.getColor
import com.common.base.utils.ViewUtils.getString
import com.module.circle.R

/**
 *
 * 作者：sosou
 *
 * 版本：1.0
 *
 * 创建日期：2025/07/23
 *
 * 描述：
 *
 * 修订历史：
 *
 */
open class CircleListSubItemAdapter(type:String?) :
    BaseQuickAdapter<CircleListModel, BaseViewHolder>(R.layout.circle_item_circle_list_sub_layout) {

    private val mType = type

    init {
        addChildClickViewIds(R.id.totalRoot)
        (getString(R.string.circle_recommendation_circle_hint) == mType).yes {
            addChildClickViewIds(R.id.tvRightBtn)
        }
    }

    override fun convert(holder: BaseViewHolder, item: CircleListModel) {
        holder.getView<ImageView>(R.id.picImg).loadRound(item.image_url, 8)
        holder.setText(R.id.tvName, item.name)
        holder.setText(R.id.tvNote, item.description)
        holder.setVisible(R.id.tvNum, item.member_count >=1)
        holder.setText(R.id.tvNum, "${item.member_count}${getString(R.string.circle_ren_splicing_hint)}")

        holder.setVisible(R.id.tvRightBtn, true)
        (getString(R.string.circle_recommendation_circle_hint) == mType).yes {
            holder.setText(R.id.tvRightBtn, getString(R.string.circle_add_circle_hint))
        }.otherwise {
            holder.setText(R.id.tvRightBtn, if (item.is_leader) getString(R.string.circle_my_create_circle_hint) else getString(R.string.circle_add_circle_hint2))
        }
        holder.setTextColor(R.id.tvRightBtn, if ((getString(R.string.circle_recommendation_circle_hint) == mType)) getColor(R.color.product_color) else getColor(R.color.c_7f7f7f))
        holder.setBackgroundResource(R.id.tvRightBtn, if ((getString(R.string.circle_recommendation_circle_hint) == mType)) R.drawable.bg_stroke_round_product8 else R.drawable.bg_stroke_round_d9d9d9_8)
    }
}